// @flow
import React, { Component } from 'react'

type Props = {
  data: Object,
  goToDevice: Function
}
class LinkToDevice extends Component {
  props: Props
  goToLink: Function
  constructor (props: Props) {
    super(props)
    this.goToLink = this.goToLink.bind(this)
  }

  goToLink () {
    const { data, goToDevice } = this.props
    goToDevice(data)
  }
  render () {
    const { name } = this.props.data
    return (
      <a onClick={this.goToLink}>
        {name}
      </a>
    )
  }
}

export default LinkToDevice
